<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>系统管理</title>
<%@ include file="/common/util.jsp"%>


<script src="${cdnctx}/dep/artDialog/jquery.artDialog.js?skin=default"></script>
<script type="text/javascript">
$(document).ready(function(){
	for ( var i = 1; i < 11; i++) {
        $("#id" + i).removeClass("current");
    }
    $("#id8").addClass("current");

});
var obj = {
	errflag : false,
	addOrUpdate: function(){
		//obj.checkLightCode();
		
		if(!obj.dataCheck()){
			$.dialog({
				icon: 'question',
				title:'确认',
				lock:true,
				width:'300px',
				content:'确定要提交吗?',
				ok: function () {
					$("#traditioncode").val($("#traditioncodeList").val());
					$("#ledcode").val($("#ledcodeList").val());
					$("form:eq(0)").submit();
				},
			    cancel: function () {
			    }
	
		});
		}
	},
	
	goback : function(){
		self.location="${cdnctx}/systemLightRelation/lightRelationMainInit.shtml";	
	},
	 dataCheck:function(){
		var msgflag = false;
		//表单验证
		var testNum =/^[0-9]+(.[0-9]{2})?$/;
		//传统灯具番号
		if($("#traditioncodeList").val()==-99){
			$("#trdmsg").html("此项不能为空！");
			$("#trdmsg").css("display","block");
			msgflag=true;
		}else{
			$("#trdmsg").css("display","none");
			
		}
		//LED灯具番号
		if($("#ledcodeList").val()==-99){
			$("#ledcodemsg").html("此项不能为空！");
			$("#ledcodemsg").css("display","block");
			msgflag =true;
		}else{
			$("#ledcodemsg").css("display","none");
			
		}
		return msgflag;
	},
	checkLightCode:function(){
	var traditioncode = $("#traditioncode").val();
	var ledcode = $("#ledcode").val();
	var param = {"traditioncode":""+traditioncode,"modifystamp":modifystamp};
		$.ajax({
			type : "POST",
			contentType : "application/json",
			url : "checkLightcode.shtml",
			data : JSON.stringify(param),
			dataType : "json",
			success: function(data){
				if(data.existFlag == true){
					$("#lcmsg").html("此灯具番号已经存在！");
					$("#lcmsg").css("display","block");
					obj.errflag =true;
				}else{
					$("#lcmsg").css("display","none");
				}
			},
			error: function(){
			}
		});
	}
	
};

</script>
</head>
<body class="main">
	<div class="-frame -style -luster" id="css_container">
		<!--首页框架页眉部分↓-->
		<%@ include file="/WEB-INF/pages/inc/header.jsp"%>
		<!--首页框架页眉部分↑-->

		<div class="content">

			<!-- Left导航菜单◎开始 -->
			<%@ include file="/WEB-INF/pages/inc/leftmenu.jsp"%>
			<!-- Left导航菜单◎结束 -->

			<div class="main-mid">
				<c:if test="${editFlag =='add' }">
					<div class="pos"><img src="${cdnctx}/src/index/img/index.png"><a href="<%--${cdnctx}/system/systemMenu.shtml--%>">系统管理  ></a><a href="${cdnctx}/systemLightRelation/lightRelationMainInit.shtml">灯具对应表管理</a><a>>添加灯具信息</a></div>
				</c:if>
				<c:if test="${editFlag =='update' }">
					<div class="pos"><img src="${cdnctx}/src/index/img/index.png"><a href="<%--${cdnctx}/system/systemMenu.shtml--%>">系统管理  ></a><a href="${cdnctx}/systemLightRelation/lightRelationMainInit.shtml">灯具对应表管理</a><a>>修改灯具信息</a></div>
				</c:if>
				
				<div class="css_contentDiv">
					<input type="hidden"
						id="modifyStamp" value="${lrEntity.modifystamp}" />
						<div class="searchDetailed  c-border-radius  b-box-shadow">
						<div id="showNodata">
						<font color="red">
						<% out.print((request.getParameter("msg") == null)?"":request.getParameter("msg"));%>
						${msg}</font>
					</div>
							<c:if test="${editFlag =='add' }">
								<form id="lightRelationInsert" action="insert.shtml"
									method="post">
							</c:if>
							<c:if test="${editFlag =='update' }">
								<form id="lightRelationUpdate" action="update.shtml"
									method="post">
							</c:if>
							<input type="hidden"  name="id" value="${lrEntity.id}"/>
							<input type="hidden"  name="modifystamp" value="${lrEntity.modifystamp}"/>
							
							<input type="hidden" id="traditioncode"   name="traditioncode" />
							<input type="hidden" id="ledcode"  name="ledcode" />
							<table align="center" width="430" border="0" cellspacing="0"
								cellpadding="0">
								<tr>
									<td width="91" height="36" class="mainText" align="right"><label><font color="red">*</font>传统灯具番号：</label>
									</td>
									<td>
									
									<select id="traditioncodeList"  style="width:200px;">
	             				 	 	<option value="-99">--请选择--</option>
	             				 	 	<c:forEach items="${traditionList}" var="entity" varStatus="status">
				                     		<option value="${entity.lightcode}"  <c:if test="${entity.lightcode == lrEntity.traditioncode}">selected</c:if>>${entity.lightcode} : ${entity.lightname}</option>
				                      	</c:forEach>
			                  		</select>
									<!-- 
									<input type="text" class="i_text" style="width:200px;"
										name="traditioncode" id="traditioncode"
										value="${lrEntity.traditioncode==''?'':lrEntity.traditioncode}"
										maxlength="11" onblur="obj.checkLightCode()" /> -->
										</td>
									<td width="120"><div id="trdmsg"
											style="display:none;color:red;"></div>
									</td>
								</tr>
								<tr>
									<td width="91" height="36" class="mainText" align="right"><label><font
											color="red">*</font>LED灯具番号：</label>
									</td>
									<td>
									
									<select id="ledcodeList"  style="width:200px;">
	             				 	 	<option value="-99">--请选择--</option>
	             				 	 	<c:forEach items="${ledList}" var="entity_led" varStatus="status">
				                     		<option value="${entity_led.lightcode}"  <c:if test="${entity_led.lightcode == lrEntity.ledcode}">selected</c:if>>${entity_led.lightcode} : ${entity_led.lightname}</option>
				                      	</c:forEach>
			                  		</select>
			                  		
									<!-- 
									<input type="text" class="i_text" style="width:200px;"
										name="ledcode" id="ledcode"
										value="${lrEntity.ledcode==''?'':lrEntity.ledcode}"
										maxlength="11" onblur="obj.checkLightCode()" /> -->
										
									<td width="120"><div id="ledcodemsg"
											style="display:none;color:red;"></div>
									</td>
								</tr>
								
								<tr>
									<td height="20"></td>
								</tr>

								<tr>
									<td></td>
									<td><input type="button" class="b-inputButton" value="保&nbsp;存"
										onclick="obj.addOrUpdate()" /> <input type="button"
										class="b-inputButton" value="返&nbsp;回" onclick="obj.goback()" /></td>

								</tr>
							</table>
							</form>
						</div>
				</div>
			</div>

		</div>

		<!--首页框架页尾部分↓-->
		<%@ include file="/WEB-INF/pages/inc/footer.jsp"%>
		<!--首页框架页尾部分↑-->
	</div>
</body>
</html>